/**
 * 
 */
package gui;

import handwritten.grid.BasicInputGridTrainning;

import java.awt.BorderLayout;
import java.awt.HeadlessException;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;


/**
 * @author tioz
 *
 */

public class JFEditorWindows extends JFrame implements GUIMaster{

	
	private static JFEditorWindows instance;
	
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private JPInputPanel inputPanel;
	private JPOutputPanel outputPanel;
	/**
	 * @throws HeadlessException
	 */
	private JFEditorWindows() throws HeadlessException {
    super("TrueMath");
   
    	BasicInputGridTrainning.terminalPrintFontList();
    	
    	ImageIcon img = new ImageIcon("picture/icon.png");
    	setIconImage(img.getImage());
    
		//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(1000,900);
		
		inputPanel = new JPInputPanel(this);
		outputPanel= new JPOutputPanel();
				
		getContentPane().setLayout(new BorderLayout());
		getContentPane().add(inputPanel, BorderLayout.CENTER);
		getContentPane().add(outputPanel,BorderLayout.SOUTH);
		
		this.addWindowListener(new WindowAdapter(){

			
			@Override
			public void windowClosing(WindowEvent e) {
				//TODO Here we should save the objects
				System.exit(0);
			}
			
		});
		
		setVisible(true);
	}


	public static JFEditorWindows getInstance(){
		if(instance != null)
			return instance;
		instance = new JFEditorWindows();
		return instance; 
	}
	

	public void paint(){
		inputPanel.repaint();
		outputPanel.repaint();
	}
	
	
	
	public InputPanel getInputPanel() {
		return inputPanel;
	}


	public JPOutputPanel getOutputPanel() {
		return outputPanel;
	}


	/**
	 * @param args
	 */
	public static void main(String[] args) {
					
		SwingUtilities.invokeLater(new Runnable(){
			public void run(){
				JFEditorWindows.getInstance();
			}
		});

	}
	
	
}

